package org.framework.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 类型转换类
 * long,int,double,string,float,boolean
 * @Author xuelongjiang
 */
public class CastUtil {


    public static long castLong(Object o){
            return Long.valueOf(o.toString());
    }

    public static int castInt(Object o){
        return Integer.valueOf(o.toString());
    }

    public static double castDouble(Object o){
        return Double.valueOf(o.toString());
    }

    public static String castString(Object o){
        return o.toString();
    }

    public static  float castFloat(Object o){
        return  Float.valueOf(o.toString());
    }

    public static boolean castBoolean(Object o){
        return Boolean.valueOf(o.toString());
    }


    public static void main(String[] args) {
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("long",1l);
        map.put("int",1);
        map.put("double",1.3);
        map.put("string","this is string");
        map.put("float",1);
        map.put("boolean",true);

        long l = castLong(map.get("long"));
        int i = castInt(map.get("int"));
        double d = castDouble(map.get("double"));
        String s1 = castString(map.get("string"));
        float f = castFloat(map.get("float"));
        boolean b = castBoolean(map.get("boolean"));
        int j =0;
        j++;



    }

}
